package com.apollographql.apollo.request;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public final class RequestHeaders {
    public static final RequestHeaders NONE = new RequestHeaders(Collections.emptyMap());
    private final Map<String, String> headerMap;

    public static Builder builder() {
        return new Builder();
    }

    public static final class Builder {
        private final Map<String, String> headerMap = new LinkedHashMap();

        public Builder addHeader(String headerName, String headerValue) {
            this.headerMap.put(headerName, headerValue);
            return this;
        }

        public Builder addHeaders(Map<String, String> headerMap2) {
            this.headerMap.putAll(headerMap2);
            return this;
        }

        public RequestHeaders build() {
            return new RequestHeaders(this.headerMap);
        }
    }

    public Builder toBuilder() {
        Builder builder = builder();
        builder.addHeaders(this.headerMap);
        return builder;
    }

    RequestHeaders(Map<String, String> headerMap2) {
        this.headerMap = headerMap2;
    }

    public Set<String> headers() {
        return this.headerMap.keySet();
    }

    public String headerValue(String header) {
        return this.headerMap.get(header);
    }

    public boolean hasHeader(String headerName) {
        return this.headerMap.containsKey(headerName);
    }
}
